package beans;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.servlet.http.HttpServletRequest;

import org.hibernate.annotations.Type;

import common.ConfigurationAppli;
import form.FileUploadForm;

@Entity
@Table(name = "FileMeta")
@NamedNativeQuery(name = "getFileMeta", query = "select * from FileMeta where clientID=?", resultClass = FileMeta.class)
public class FileMeta implements Serializable{

    @Transient
    ConfigurationAppli conf;
    @Transient
    private static final String ATT_USER_NAME= ConfigurationAppli.getInstance().getValue("ATT_USER_NAME");
    @Transient
    private static final String ATT_CLIENT_INFO_ID = ConfigurationAppli.getInstance().getValue("ATT_CLIENT_INFO_ID");
    @Transient
    private String              fileName; 
    
    public String getFileName() {
        String x =filepath.split( "\\\\" )[ (filepath.split("\\\\").length)-1];
        
        return x;
    }

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    private long                id;
    private long                clientID;
    private String              userName;
    @Type(type="text")
    private String              fileDesc;
    private String              filepath;
    private Date                fileDescDate;
    
    FileMeta()
    {
        conf=ConfigurationAppli.getInstance();
    }
    
    public FileMeta(long clientID, String userName, String fileDesc, String filePath)
    {
        this.clientID=clientID;
        this.userName=userName;
        this.fileDesc = fileDesc;
        this.filepath = filePath;
        this.fileDescDate = new Date();
    }

    // getters setters -------------------------------------------------------
    // -----------------------------------------------------------------------


    public long getId() {
        return id;
    }

    public void setId( long id ) {
        this.id = id;
    }

    public long getClientID() {
        return clientID;
    }

    public void setClientID( long clientID ) {
        this.clientID = clientID;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName( String userName ) {
        this.userName = userName;
    }

    public String getFileDesc() {
        return fileDesc;
    }

    public void setFileDesc( String fileDesc ) {
        this.fileDesc = fileDesc;
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath( String filepath ) {
        this.filepath = filepath;
    }

    public Date getFileDescDate() {
        return fileDescDate;
    }

    public void setFileDescDate( Date fileDescDate ) {
        this.fileDescDate = fileDescDate;
    }

    
}
